<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>JSONP跨域请求</h1>

    <button>JSONP的跨域访问</button>

    <script>
        // 获取按钮
        const bn = document.querySelector("button");
        bn.onclick = function(){
            // 动态的创建一个 script 标签
            const script = document.createElement("script");
            // 指定src属性：
            script.src = "http://localhost:3000/testAJAX?callback=demo";
            // 将 script 添加到 body 中（将script节点添加到页面中）
            document.body.appendChild(script);
        }

        function demo(data){
            console.log(data);
        }

    </script>




    <!-- <script>
        // script 标签的跨域能力操作
        function abc(data){
            console.log(data);
        }
    </script>
    <script src="http://127.0.0.1:3000/js/aa.js"></script> -->
</body>
</html>